<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="Content-Language" content="zh-CN"/>
        <meta name="robots" content="index, follow" />
        <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
        <title>氿上网</title>
        <?php echo $this->_var['system_css']; ?>
        <?php echo $this->_var['system_js']; ?>
        <script>
            var editor;
            KindEditor.ready(function(K) {
                editor = K.create('textarea[name="content"]', {
                    resizeType : 1,
                    allowPreviewEmoticons : false,
                    allowImageUpload : false,
                    items : [
                        'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                        'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                        'insertunorderedlist', '|', 'emoticons', 'image']
                });
            });
        </script>
        <script type="text/javascript">
            $(function(){
                $("#myform").validate({
                    rules: {
                        
                        qq:{
                            number:true,
                            maxlength:11
                        },
                        mobile_phone: {
                            maxlength:11,
                            minlength:11,
                            number:true

                        },
                        province: "required"
                    },
                    messages: {
                        qq:{
                            maxlength:'qq位数不能超过11位',
                            number:'QQ必须为数字'
                        },
                        mobile_phone:{
                            minlength:'手机号码必须为11位',
                            maxlength:'手机号码必须为11位',
                            number:'手机号码必须为数字'
                        },
                        province: "请选择所在地!"
                    }
                });
            })
        </script>
    </head>
    <body>

        <div id="OSC_Screen">
            <?php echo $this->fetch('header.html'); ?>
            <div id="OSC_Content" class='CenterDiv'>
                <?php echo $this->fetch('user_nav.html'); ?>
                <?php echo $this->fetch('message.html'); ?>
                <div class="MainForm" id="reg_page">

                    <form id="myform" name="myform" action="<?php echo $this->_var['site_url']; ?>shop/add" method="post" style="float:left; width:700px;" enctype="MULTIPART/FORM-DATA" >
                        <table cellspacing='0' cellpadding='0'>
                            <tr id='tr_user'>
                                <th >产品图片：</th>
                                <td>
                                    <input type="file" name="avatar" id="avatar" /><input type="submit" value="上传" />
                                </td>    			
                            </tr>

                            <tr id='tr_user'>
                                <th >产品名称：</th>
                                <td>
                                    <input type='text' name='name' id='name'  class='TEXT' style='width:500px;'/>
                                </td>    			
                            </tr>

                            <tr id='tr_user'>
                                <th >产品价格：</th>
                                <td>
                                    <input type='text' name='goods_images' id='goods_images'  class='TEXT' style='width:200px;'/>
                                </td>    			
                            </tr>
                            <tr id='tr_user'>
                                <th >产品分类：</th>
                                <td id="category_id">
                                    <select class='category_id' name='category_id[]' onchange='change_category(this)'>
                                        <?php echo $this->_var['category_option']; ?>
                                    </select>
                                </td>    			
                            </tr>

                            <tr id='tr_user'>
                                <th >是否上架：</th>
                                <td>
                                    <input type="radio" name="is_show" value="1" checked="true" id="show_1"/><label for="show_1">是</label>
                                    <input type="radio" name="is_show" value="0"  id="show_0"/><label for="show_0">否</label>
                                </td>    			
                            </tr>

                            <tr id='tr_user'>
                                <th >是否推荐：</th>
                                <td>
                                    <input type="radio" name="is_recommend" value="1"  id="recommend_1"/><label for="recommend_1">是</label>
                                    <input type="radio" name="is_recommend" value="0"  id="recommend_0" checked="true"/><label for="recommend_0">否</label>
                                </td>    			
                            </tr>

                            <tr id='tr_user'>
                                <th >详细介绍：</th>
                                <td>
                                    <textarea name="content" id="content" style="width:600px;height:220px;"></textarea>
                                </td>    			
                            </tr>
                            <tr class='buttons'>
                                <th>&nbsp;</th>		
                                <td style='padding:20px 0;'>
                                    <input type='submit' value=' 更改 ' class='BUTTON SUBMIT'/><br/><br/>
                                </td>
                            </tr>
                        </table>
                    </form>
                    <div class='clear'></div>
                </div>

            </div>
            <div class='clear'></div></div>
        <div class='clear'></div>
        <?php echo $this->fetch('footer.html'); ?>
        </div>

        <script>
            
            $(function(){
                var category_id = $('.category_id').val();
                if(category_id != ''){
                    $.ajax({
                        url:"<?php echo $this->_var['site_url']; ?>admin/ajax/category_sub",
                        type:'post',
                        dataType:'html',
                        data:'id='+category_id,
                        success:function(data){
                            if(data != ''){
                                var html = "<select class='category_id' name='category_id[]' onchange='change_category(this)'><option value='0'>==不选择==</option>";
                                html +=data+"</select>";
                                $('#category_id').append(html);
                            } else{
                                $(this).next('.category_id').remove();
                            }
                        }
                    });
                }
                
                $('.category_id').change(function(){
                    $(this).next('.category_id').remove();
                })
            });
            
            
            function change_category(category_sub){
                $('.category_id').change(function(){
                    $(this).next('.category_id').remove();
                })
                $.ajax({
                    url:"<?php echo $this->_var['site_url']; ?>admin/ajax/category_sub",
                    type:'post',
                    dataType:'html',
                    data:'id='+category_sub.value,
                    success:function(data){
                        if(data != ''){
                            var html = "<select class='category_id' name='category_id[]' onchange='change_category(this)'><option value='0'>==不选择==</option>";
                            html +=data+"</select>";
                            $('#category_id').append(html);
                        } else{
                            $(this).next('.category_id').remove();
                        }
                    }
                });
            }
        </script>
    </body>
</html>
